﻿/*******************************************************************数据加载**************************************************************************************************************************/
function DataBindNoPager(pagename, isFirst, param, wait, statustext, head, show, more, pagesize, pageindex) {
    if (isFirst == 1) {
        $("#" + wait).show();
        $("#" + more).hide();

    }
    else if (isFirst == 0) {
        $("#" + more).show();
        $("#" + wait).hide();
    }
    var $strpara = strChange(param, pagesize, pageindex);


    var $params = eval('(' + $strpara + ')');

    $.ajaxForGet(pagename,
                           $params,
                            function () {
                                if (isFirst == 1) {
                                    $("#" + wait).html('<div id="dvMsg" style="font-size:12;text-align:center;"><img src="../../img/wait1.gif" alt="" />&nbsp;&nbsp;' + statustext + '</div>');
                                }
                                else if (isFirst == 0) {
                                    $("#" + more).html('<div id="dvMsg" style="font-size:12;text-align:center;"><img src="../../img/wait1.gif" alt="" />&nbsp;&nbsp;' + statustext + '</div>');
                                }
                            },
                            function (responseText) {
                                //$("#" + head).show();
                                if (isFirst == 1) {
                                    //$("#" + show).html(responseText).find(".trcreate").remove();
                                    $("#" + show).html(responseText);
                                }
                                else if (isFirst == 0) {
                                    //$("#" + show).append(responseText).find(".trcreate").remove();
                                    $("#" + show).html(responseText);
                                }
                                $("#" + wait).hide();
                                $("#" + more).hide();
                            });
}

function DataBind(pagename, param, wait, statustext, show, dvpager, pagesize, pageindex) {
    var $strpara = strChange(param, pagesize, pageindex);
    var $params = eval('(' + $strpara + ')');
    $.ajaxForGet(pagename,
                           $params,
                            function () {
                                $("#" + wait).show();
                                $("#" + wait).html('<div id="dvMsg" style="font-size:12;text-align:center;"><img src="../../img/wait1.gif" alt="" />&nbsp;&nbsp;' + statustext + '</div>');
                            },
                            function (responseText) {
                                $("#" + show).html(responseText);
                                $("#" + wait).hide();
                                //获取数据总数
                                var $rowcount = parseInt($("#aTotal").html());
                                $.createPager(dvpager, $rowcount, pageindex, pagesize, "5", "1", "上一页", "下一页", "......", function (page_id, jq) { DataBind(pagename, param, wait, statustext, show, dvpager, pagesize, page_id); });
                            });
   
}

function strChange(strparam, pagesize, pageindex) {
    var $strDouble = '"';
    var $sArray = strparam.split("|");
    strReturn = "{" + $strDouble + "pageSize" + $strDouble + ":" + $strDouble + pagesize + $strDouble + "," + $strDouble + "pageIndex" + $strDouble + ":" + $strDouble + pageindex + $strDouble;
    for (var i = 0; i < $sArray.length; i++) {
        if (i < $sArray.length - 1)
            strReturn = strReturn + "," + $strDouble + $sArray[i].split("/")[0] + $strDouble + ":" + $strDouble + $sArray[i].split("/")[1] + $strDouble + ","
        else
            strReturn = strReturn + "," + $strDouble + $sArray[i].split("/")[0] + $strDouble + ":" + $strDouble + $sArray[i].split("/")[1] + $strDouble
    }
    strReturn = strReturn + "}";
    return strReturn;
}

function strList(strKey, strValue) {
    var strReturn = strKey + "/" + strValue;
    return strReturn;
}
/********************************************************************************************************************************************************************************************************/

